<?php

namespace frontend\models;

use Yii;

/**
 * This is the model class for table "{{%job}}".
 *
 * @property integer $job_id
 * @property string $job_name
 * @property string $job_area
 * @property string $user_id
 * @property string $job_desc
 * @property string $job_status
 * @property integer $job_salary
 * @property integer $job_time
 * @property integer $start_time
 * @property integer $end_time
 * @property integer $job_typeid
 * @property integer $job_num
 * @property integer $user_addtime
 * @property integer $seven_typeid
 *
 * @property Apply $apply
 * @property Type $sevenType
 */
class JobModel extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%job}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['job_desc'], 'string'],
            [['job_salary', 'job_time', 'start_time', 'end_time', 'job_typeid', 'job_num', 'user_addtime', 'seven_typeid'], 'integer'],
            [['seven_typeid'], 'required'],
            [['job_name', 'job_area', 'user_id', 'job_status'], 'string', 'max' => 45],
            [['seven_typeid'], 'exist', 'skipOnError' => true, 'targetClass' => Type::className(), 'targetAttribute' => ['seven_typeid' => 'type_id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'job_id' => Yii::t('app', 'Job ID'),
            'job_name' => Yii::t('app', 'Job Name'),
            'job_area' => Yii::t('app', 'Job Area'),
            'user_id' => Yii::t('app', 'User ID'),
            'job_desc' => Yii::t('app', 'Job Desc'),
            'job_status' => Yii::t('app', 'Job Status'),
            'job_salary' => Yii::t('app', 'Job Salary'),
            'job_time' => Yii::t('app', 'Job Time'),
            'start_time' => Yii::t('app', 'Start Time'),
            'end_time' => Yii::t('app', 'End Time'),
            'job_typeid' => Yii::t('app', 'Job Typeid'),
            'job_num' => Yii::t('app', 'Job Num'),
            'user_addtime' => Yii::t('app', 'User Addtime'),
            'seven_typeid' => Yii::t('app', 'Seven Typeid'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getApply()
    {
        return $this->hasOne(Apply::className(), ['apply_id' => 'job_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getSevenType()
    {
        return $this->hasOne(Type::className(), ['type_id' => 'seven_typeid']);
    }
}
